import { jsPDF } from 'jspdf';

class Pdf {
  constructor(container) {
    const pdfContainer = typeof container === 'string' ? document.querySelector(container) : container;
    const doc = new jsPDF();

    doc.text('Hello DevUI!', 10, 10);

    doc.textWithLink('https://devui.design/', 10, 20, {
      url: 'https://devui.design/'
    });

    const img = new Image();
    img.src = 'assets/images/devui-logo.png';
    doc.addImage(img, 'png', 10, 30, 60, 60);

    const output = doc.output('datauristring');
    pdfContainer.src = output;
  }
}

export default Pdf;
